#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QPushButton* button = new QPushButton(this);

    //将按钮和发送信号的槽函数绑定起来
    connect(button, &QPushButton::clicked, this, &Widget::EmitMySignal);
    //将自定义信号和修改窗口名称槽函数绑定起来
    connect(this, &Widget::MySignal, this, &Widget::MySlot);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::MySlot()
{
    this->setWindowTitle("hello world");
}

void Widget::EmitMySignal()
{
    emit MySignal();
}

